<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
	<%@ page import="org.springframework.security.core.context.SecurityContextHolder, java.util.List" %>
	<%
		Boolean isAuthorized = true;
		//isAuthenticated = SecurityContextHolder.getContext().getAuthentication().isAuthenticated();
		if (SecurityContextHolder.getContext().getAuthentication().getName().equals("anonymousUser")) {
			isAuthorized = false;
		}
	%>
	<div id="right_sidebar">
	<% if (!isAuthorized) {%>
		<form class="form-signin" style="width: 220px" action="<c:url value='j_spring_security_check' />" method="POST">
			<h4 class="form-signin-heading">Please sign in</h4>
			<input type="text" class="form-control" placeholder="Login" autofocus name="j_username">
			<input type="password" class="form-control" placeholder="Password" name="j_password">
			<button class="btn btn-lg btn-inverse btn-block" type="submit">Sign in</button>
		</form>
	<%} else {%>
		<h4>Hello, <%= SecurityContextHolder.getContext().getAuthentication().getName() %></h4>
		<button class="btn btn-lg btn-inverse btn-block" 
				type="button" 
				onclick="location.href='/catalog/j_spring_security_logout'">
			Logout
		</button>
	<%} %>
	</div>
</body>
</html>